//
//  AddBackBoxPlanListVC.m
//  ReceiptDelivery
//
//  Created by 吕晶 on 2020/7/30.
//  Copyright © 2020 吕晶. All rights reserved.
//

#import "AddBackBoxPlanListVC.h"
#import "BackBoxPlanModel.h"
#import "BackBoxPlanCell.h"
#import "AddLadingBillVC.h"

@interface AddBackBoxPlanListVC ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) NSMutableArray <BackBoxPlanModel *>*array;
@property (nonatomic, strong) UITableView *tableView;

@end

@implementation AddBackBoxPlanListVC

-(NSMutableArray<BackBoxPlanModel *> *)array {
    if (!_array) {
        _array = [NSMutableArray array];
        BackBoxPlanModel *model = [BackBoxPlanModel new];
        model.company = @"德邦物流有限公司";
        model.tiHuoCompany = @"苏州观致汽车有限公司";
        model.tiHuoAddress = @"苏州市金猫路9号苏州市金猫路9号苏州市金猫路9号苏州市金猫路9号苏州市金猫路9号苏州市金猫路9号苏州市金猫路9号";
        model.boxCount = 12;
        [_array addObject:model];
        [_array addObject:model];
    }
    return _array;
}

-(UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenW, ScreenH - BottomHeight - NaviHeight) style:UITableViewStyleGrouped];
        _tableView.backgroundColor = Color_backgroundColor;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    return _tableView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"新建返箱计划";
    [self.view addSubview:self.tableView];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.array.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    BackBoxPlanCell *cell = [BackBoxPlanCell BackBoxPlanCellWithTableView:tableView];
    cell.model = self.array[indexPath.row];
    __weak_self;
    cell.newBlock = ^{
        AddLadingBillVC *vc = [AddLadingBillVC new];
        [weakself.rt_navigationController pushViewController:vc animated:YES];
    };
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    BackBoxPlanCell *cell = [BackBoxPlanCell BackBoxPlanCellWithTableView:tableView];
    cell.model = self.array[indexPath.row];
    return cell.height;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenW, 10)];
    view.backgroundColor = Color_backgroundColor;
    return view;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 10;
}

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return [UIView new];
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
